<?php
	$cfid = get('cfid');

	if(isPost()){
    	$db=getDB();
        $list = post('item');        
        foreach($list AS $k => $v){
        	$set = array();
            $set['Fcontents'] = $v;
            if($db->get_row(sprintf("SELECT * FROM t_class_content WHERE Fcssnameid=%d AND Fclassid=%d",$cfid,$k))){
            	$db->updateTable('t_class_content',$set,sprintf("Fcssnameid=%d AND Fclassid=%d",$cfid,$k));
            }else{
                $set['Fcssnameid'] = $cfid;
                $set['Fclassid'] = $k;
                $db->insertTable('t_class_content',$set);
            }
        }
        
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="base.css" rel="stylesheet" type="text/css" />
</head>
<body>

<form action="?ac=csscontent&cfid=<?php echo $cfid;?>" method="post">
	<table  border="0" cellspacing="1" cellpadding="1">
  <tr class="trheader">
    <td>class</td>
    <td>css内容</td>
  </tr>
  <?php
  	$db = getDB();
    $list = $db->get_results("SELECT t_css_base.*,t_class_content.Fcontents,t_class_content.Fcssnameid FROM t_css_base JOIN t_class_content ON t_class_content.Fclassid=t_css_base.Fid");
    if($list){
    	foreach($list AS $row){
        	if($row['Fcssnameid'] AND $row['Fcssnameid'] != $cfid){
var_dump($row);            	continue;
            }
        	echo sprintf('<tr><td>%s</td><td><input name="item[%d]" type="text" value="%s" /></td></tr>',$row['Fclassname'],$row['Fid'],$row['Fcontents']);
        }
    }
  ?>
        </table>
<input name="" type="submit" />
</form>
</body>
</html>
